const fs = require('fs');
const path = require('path');

const code = fs.readFileSync(path.resolve(__dirname, 'code.js'), 'utf-8');
const OUT_DIR = 'output';
const ast = require("@babel/core").parse(code, {
    sourceType: "module",
});

// TO CODE  
const { code: code2 } = require('@babel/generator').default(ast)

fs.writeFileSync(path.resolve(OUT_DIR, 'result.js'), code2, 'utf-8');